import {
  Navigate,
  createBrowserRouter,
  createHashRouter,
} from "react-router-dom";
import { getReactRouter, useLayout } from "@/.utils/routerRender";
import Index from "@/views/index";
import ApiView from "@/views/ApiView";
import DocCom from "@/views/DocCom";

// import { HashRouter } from "react-router-dom";
const Router: MasRouter = [
  {
    hideMenu: true,
    path: "/",
    element: <Navigate to={"/index"} />,
  },
  {
    label: "首页",
    path: "/index",
    element: <Index />,
  },
  {
    label: "调用文档",
    path: "/doc",
    element: <DocCom />,
  },
  {
    label: "接口",
    path: "/api/*",
    element: <ApiView />,
  },
  {
    path: "/403",
    element: "403",
    hideMenu: true,
  },
  {
    path: "*",
    element: "404",
    hideMenu: true,
  },
];

const { reactRouter, accessArr } = getReactRouter(useLayout(Router));
// eslint-disable-next-line react-refresh/only-export-components
export const router = createHashRouter(reactRouter);
// eslint-disable-next-line react-refresh/only-export-components
export const routerAccessData = accessArr;
export const RouterIndex = Router;
